﻿/*
SINACOR - BMF&Bovespa
Arquivo: NoNaturezaOperacao.cs
Criado em: 07-abr-2010 15:53:20
Arquiteto Responsável: p-RAMelo
*/
using System;
using System.Collections.Generic;
using System.Text;
using Sinacor.Infra.UI.Common;


namespace Sinacor.UI.Bovespa.ManutencaoOrdens.Model 
{
	/// <summary>
	/// Nó representa a natureza da operação
	/// </summary>
	[Serializable]
	public class NoNaturezaOperacao : BaseModel, Sinacor.Infra.UI.Common.IHierarchicalItem<Model.NoTitulo,Model.NoTipoObjetoConsulta,ModelCollection<Model.NoTipoObjetoConsulta>> 
	{

		#region Construtor

		/// <summary>
		/// Construtor padrão
		/// </summary>
		/// <param name="parent"></param>
		/// <param name="natureza"></param>
		public NoNaturezaOperacao(Model.NoTitulo parent, Model.Enum.NaturezaOperacao natureza)
		{
            _parent = parent;
			_natureza = natureza;
            _children = new ModelCollection<NoTipoObjetoConsulta>();
		}

		#endregion

		#region Atributos

		private ModelCollection<Model.NoTipoObjetoConsulta> _children = null;
		private Model.Enum.NaturezaOperacao _natureza;
		private Model.NoTitulo _parent = null;

		#endregion

		#region Propriedades

        /// <summary>
        /// Children
        /// </summary>
        /// <returns></returns>
		public ModelCollection<Model.NoTipoObjetoConsulta> Children
		{
            get 
            { 
                return _children; 
            }           
		}


        /// <summary>
        /// Children
        /// </summary>
        /// <returns></returns>
		System.Collections.IEnumerable Sinacor.Infra.UI.Common.IHierarchicalItem.Children
		{
            get { return (System.Collections.IEnumerable)_children; }
		}

		/// <summary>
		/// Natureza da operação
		/// </summary>
		public Model.Enum.NaturezaOperacao Natureza
		{

            get { return _natureza; }
		}

        /// <summary>
        /// Parent
        /// </summary>
        /// <returns></returns>
		public Model.NoTitulo Parent
		{
            get 
            { 
                return _parent; 
            }
            set
            {
                SetValue<Model.NoTitulo>("Parent", ref _parent, value);
            }
		}

        /// <summary>
        /// Parent
        /// </summary>
        Sinacor.Infra.UI.Common.IHierarchicalItem Sinacor.Infra.UI.Common.IHierarchicalItem.Parent
        {
            get { return (Sinacor.Infra.UI.Common.IHierarchicalItem)_parent; }
        }

        /// <summary>
        /// Text
        /// </summary>
        /// <returns></returns>
		public String Text
		{
            get 
            {
                if(_natureza == Model.Enum.NaturezaOperacao.Compra)
                    return PSE.Framework.UI.Resources.ResourceProviderManager.GetResourceProvider().TryGetResource("Bovespa.ManutencaoOrdens.Label.Compra").ToString();
                else
                    return PSE.Framework.UI.Resources.ResourceProviderManager.GetResourceProvider().TryGetResource("Bovespa.ManutencaoOrdens.Label.Venda").ToString();                        
            }
		}

		#endregion

	}

}